from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time


def login():
    # 实例化一个启动的参数对象
    option = Options()
    # "设置浏览器窗口最大化
    option.add_argument("--start-maximized")
    # 引用option
    driver = webdriver.Chrome(option)

    # 进入到玩安卓界面
    driver.get("https://www.wanandroid.com/")
    # 点击登录
    driver.find_element(By.XPATH, "/html/body/div[1]/div[1]/div/div[3]/ul/li[1]/a").click()
    time.sleep(2)
    # 输入账号
    driver.find_element(By.XPATH, "//*[@id='loginDialog']/div/input[1]").send_keys("liangchao")
    time.sleep(2)
    # 输入密码
    driver.find_element(By.XPATH, "//*[@id='loginDialog']/div/input[2]").send_keys("123456")
    time.sleep(2)
    # 点击登录
    driver.find_element(By.XPATH, "//*[@id='loginDialog']/div/p[3]/span").click()
    time.sleep(5)
    # 关闭浏览器
    driver.quit()


if __name__ == '__main__':
    login()
